﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 晨曦超市管理系统.员工管理
{
    public partial class Modification2 : Form
    {
        public Modification2()
        {
            InitializeComponent();
        }
        public DataGridViewRow dr;
        private void Modification2_Load(object sender, EventArgs e)
        {
            //获取当前行的值，在前面一个界面我已经获取行了
            textBox1.Text = dr.Cells[0].Value.ToString();
            comboBox1.Text = dr.Cells[1].Value.ToString();
            textBox9.Text = dr.Cells[2].Value.ToString();
            textBox8.Text = dr.Cells[3].Value.ToString();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                string Name = textBox1.Text.Trim();
                string UserNameID = textBox9.Text.Trim();
                string Paw = textBox8.Text.Trim();
                string Position = comboBox1.Text.Trim();
                string ID = dr.Cells[0].Value.ToString();
                string sqlstr = "update informationOfEmployees set Name='" + Name + "',UserNameID='" + UserNameID + "',Paw='" + Paw + "',Position='" + Position + "' where Name='" + ID + "'";
                bool duicuo = DBHelper.QEX(sqlstr);
                if (duicuo)
                {
                    MessageBox.Show("修改成功");
                    textBox1.Text = "";
                    textBox9.Text = "";
                    textBox8.Text = "";
                }
                else
                {
                    MessageBox.Show("修改失败");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
